package com.xayy.health.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import com.xayy.health.core.enums.FaultLevelEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 故障信息
 *
 * @author cuixidong
 * @version 1.0
 * @date 2023/4/6 11:37
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "HEALTH.tb_fault_info")
@EqualsAndHashCode(callSuper = true)
public class FaultInfo extends BaseModel<Long> {

    @Id
    @Column(name = "id")
    private Long id;

    @Column(name = "lead_id")
    @ApiModelProperty(value = "外部引接id")
    private String leadId;

    @Column(name = "satellite_id")
    @ApiModelProperty(value = "卫星id")
    private Long satelliteId;

    @Column(name = "satellite_code")
    @ApiModelProperty(value = "卫星代号")
    private String satelliteCode;

    @Column(name = "satellite_name")
    @ApiModelProperty(value = "卫星名称")
    private String satelliteName;


    @Column(name = "system_id")
    @ApiModelProperty(value = "分系统id")
    private Long systemId;

    @Column(name = "system_name")
    @ApiModelProperty(value = "分系统名称")
    private String systemName;


    @Column(name = "node_id")
    @ApiModelProperty(value = "部件id")
    private Long nodeId;

    @Column(name = "node_name")
    @ApiModelProperty(value = "部件名称")
    private String nodeName;



    @Column(name = "param_code")
    @ApiModelProperty(value = "参数代号")
    private String paramCode;

    @Column(name = "param_name")
    @ApiModelProperty(value = "参数名称")
    private String paramName;



    @Column(name = "fault_level")
    @ApiModelProperty(value = "故障等级(1 轻微，2 一般，3 严重，4 致命)")
    private Integer faultLevel;

    @Transient
    private String faultLevelName;

    @Column(name = "diagnose_time")
    @ApiModelProperty(value = "故障时间")
    private Date diagnoseTime;

    @Column(name = "description")
    @ApiModelProperty(value = "故障现象")
    private String description;

    @Column(name = "source")
    @ApiModelProperty(value = "来源(1 任务系统，2 事后诊断，3 异常分析，4 趋势预测，5外部引接)")
    private Integer source;

    @Override
    public Long idValue() {
        return id;
    }

    public void setFaultLevel(Integer faultLevel) {
        this.faultLevel = faultLevel;
        this.faultLevelName = FaultLevelEnum.valueof(faultLevel);
    }
}

